package com.tmt.im.manager.helper;

import com.tmt.im.jpa.entity.IMFriendApply;
import com.tmt.springboot.common.annotation._ReflectInvoked;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/25 15:28
 * @Version 1.0
 **/
public class IMFriendApplyHelper {

    @_ReflectInvoked
    public static Long getGroupId(IMFriendApply apply) {
        return apply.getGroup() != null ? apply.getGroup().getId() : null;
    }

    @_ReflectInvoked
    public static String getGroupName(IMFriendApply apply) {
        return apply.getGroup() != null ? apply.getGroup().getName() : null;
    }

    @_ReflectInvoked
    public static String getModeDescr(IMFriendApply apply) {
        return apply.getMode() != null ? apply.getMode().getMsg() : null;
    }

    @_ReflectInvoked
    public static int getReviewStatus(IMFriendApply apply) {
        if (apply.getReviewTime() == null) {
            return 0;
        }
        return apply.isReviewStatus() ? 1 : 2;
    }

    @_ReflectInvoked
    public static int getGrade(IMFriendApply apply) {
        return apply.getFriend().getGrade() != null ? apply.getFriend().getGrade() : 0;
    }

    @_ReflectInvoked
    public static int getGrade1(IMFriendApply apply) {
        return apply.getCreator().getGrade() != null ? apply.getCreator().getGrade() : 0;
    }

    public static Long getCreateTime(IMFriendApply apply){
        return apply.getCreateTime() != null ? apply.getCreateTime().getTime() : null;
    }
}
